#include <pthread.h>
#include <iostream>
namespace MutexModule
{
    class Mutex
    {
        public:
        Mutex(pthread_mutex_t& mutex)
            :_mutex(mutex)
        {
            int n = pthread_mutex_init(&_mutex,nullptr);
            (void)n;
        }

        ~Mutex()
        {
            pthread_mutex_destroy(&_mutex);
        }

        void Lock()
        {
            int n = pthread_mutex_lock(&_mutex);
            (void)n;
        }

        void Unlock()
        {
            int n = pthread_mutex_unlock(&_mutex);
            (void)n;
        }
        private:
        pthread_mutex_t _mutex;
    };

}


class LockGuard
{
    public:
    LockGuard(pthread_mutex_t& mutex)
        :_mutex(mutex)
    {
        pthread_mutex_init(&_mutex,nullptr);
    }

    ~LockGuard()
    {
        pthread_mutex_unlock(&_mutex);
    }
    private:
    pthread_mutex_t& _mutex;
};